package com.xpgk.mvc.bchargeDebt;

import java.util.List;
import java.util.Map;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.productSales.ProductSales;

public class BchargeDebtController extends BaseController{
	
	private BchargeDebtService  bchargeDebtService;
	public  void  index()
	{
		render("BchargeDebt.html");
	}
	/**获取顾客欠款信息
	 * 
	 */
	public void getQkOrder()
	{	
		String  cusIds=getPara("customerIds");
		
		Map<String, Object> mm=bchargeDebtService.getQkOrder(cusIds, getCUserOrganIds());
		renderJson(mm);
	}
	
	/**展开订单详情
	 * 
	 */
	public void showOrder()
	{
		String  orderIds=getPara("orderIds");
		setAttr("orderIds", orderIds);
		render("receivables.html");
	}
	/**
	 * 获取订单详情
	 */
	public void orderInfo()
	{
		String  orderIds=getPara("orderIds");
		List<ProductSales>  psList=ProductSales.dao.getProductSaless(orderIds, getCUserOrganIds());
		renderJson(psList);
	}
	
	
	/**还款
	 * 
	 */
	@Before(Tx.class)
	public  void  repayment()
	{
		String  organIds=getCUserOrganIds();
		String  userIds=getCUserIds();
		CollectArrears  ca=getModel(CollectArrears.class);
		String  msg=bchargeDebtService.repayment(organIds,userIds,ca);
		renderText(msg);
	}
}
